home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / IEditor / Generators / E / arexx.c next >
Encoding:
C/C++ Source or Header  |  1997-06-17  |  4.3 KB  |  153 lines

  1. /// Includes
  2. #define INTUI_V36_NAMES_ONLY
  3.  
  4. #include <exec/types.h>                 // exec
  5. #include <exec/lists.h>
  6. #include <exec/nodes.h>
  7. #include <dos/dos.h>                    // dos
  8. #include <clib/exec_protos.h>           // protos
  9. #include <clib/dos_protos.h>
  10. #include <pragmas/exec_pragmas.h>       // pragmas
  11. #include <pragmas/dos_pragmas.h>
  12.  
  13. #include <string.h>
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <ctype.h>
  17.  
  18. #include "DEV_IE:Generators/defs.h"
  19. #include "DEV_IE:Include/IEditor.h"
  20. #include "DEV_IE:Generators/C/Protos.h"
  21. ///
  22.  
  23.  
  24. /// WriteRexxCmds
  25. void WriteRexxCmds( struct GenFiles *Files, struct IE_Data *IE )
  26. {
  27.     struct RexxNode *rx;
  28.  
  29.     if( IE->NumRexxs ) {
  30.  
  31.     FPuts( Files->XDef, "extern UWORD\t\t\tRX_Unconfirmed;\n"
  32.                 "extern struct MsgPort\t\t*RexxPort;\n"
  33.                 "extern UBYTE\t\t\tRexxPortName[];\n"
  34.                 "extern BOOL SetupRexxPort( void );\n"
  35.                 "extern void DeleteRexxPort( void );\n"
  36.                 "extern void HandleRexxMsg( void );\n"
  37.                 "extern BOOL SendRexxMsg( char *Host, char *Ext, char *Command, APTR Msg, LONG Flags );\n" );
  38.  
  39.     if( IE->SrcFlags & AREXX_CMD_LIST ) {
  40.         FPuts( Files->XDef, "extern struct MinList\t\tRexxCommands;\n"
  41.                 "\n"
  42.                 "struct CmdNode {\n"
  43.                 "\tstruct Node\tNode;\n"
  44.                 "\tSTRPTR\tTemplate;\n"
  45.                 "\tLONG\t( *Routine )( ULONG *, struct RexxMsg * );\n"
  46.                 "};\n" );
  47.     } else
  48.         FPuts( Files->Std, "\nstatic struct parser { char *command; char *template; LONG (*routine)(ULONG *, struct RexxMsg *); } CmdTable[] = {\n" );
  49.  
  50.     for( rx = IE->Rexx_List.mlh_Head; rx->rxn_Node.ln_Succ; rx = rx->rxn_Node.ln_Succ ) {
  51.  
  52.         FPrintf( Files->XDef, "extern LONG %sRexxed( ULONG *ArgArray, struct RexxMsg *Msg );\n",
  53.              rx->rxn_Label );
  54.  
  55.         if( IE->C_Prefs & GEN_TEMPLATE )
  56.         FPrintf( Files->Temp, "\nLONG %sRexxed( ULONG *ArgArray, struct RexxMsg *Msg )\n"
  57.                       "{\n"
  58.                       "\t/*  Routine for the \"%s\" ARexx command  */\n"
  59.                       "\treturn( 0L );\n"
  60.                       "}\n",
  61.              rx->rxn_Label, rx->rxn_Name );
  62.     }
  63.  
  64.  
  65.     if( IE->SrcFlags & AREXX_CMD_LIST ) {
  66.  
  67.         FPuts( Files->Std, "\nstatic struct CmdNode RexxCmds[] = {\n\t" );
  68.  
  69.         rx = IE->Rexx_List.mlh_Head;
  70.  
  71.         if( IE->NumRexxs == 1 ) {
  72.         FPuts( Files->Std, "(struct CmdNode *)&RexxCommands.mlh_Tail, (struct CmdNode *)&RexxCommands.mlh_Head, 0, 0, " );
  73.  
  74.         FPrintf( Files->Std, "\"%s\", ", rx->rxn_Name );
  75.  
  76.         if( rx->rxn_Template[0] )
  77.             FPrintf( Files->Std, "\"%s\"", rx->rxn_Template );
  78.         else
  79.             FPuts( Files->Std, Null );
  80.  
  81.         FPrintf( Files->Std, ", (APTR)%sRexxed\n", rx->rxn_Label );
  82.  
  83.         FPuts( Files->Std, " };\n" );
  84.         } else {
  85.  
  86.         FPuts( Files->Std, "&RexxCmds[1], (struct Node *)&RexxCommands.mlh_Head, 0, 0, " );
  87.  
  88.         FPrintf( Files->Std, "\"%s\", ", rx->rxn_Name );
  89.  
  90.         if( rx->rxn_Template[0] )
  91.             FPrintf( Files->Std, "\"%s\"", rx->rxn_Template );
  92.         else
  93.             FPuts( Files->Std, Null );
  94.  
  95.         FPrintf( Files->Std, ", (APTR)%sRexxed,\n", rx->rxn_Label );
  96.  
  97.         ULONG   cnt;
  98.         for( cnt = 1; cnt < IE->NumRexxs - 1; cnt++ ) {
  99.  
  100.             rx = rx->rxn_Node.ln_Succ;
  101.  
  102.             FPrintf( Files->Std, "\t&RexxCmds[%ld], &RexxCmds[%ld], 0, 0, ",
  103.                  cnt + 1, cnt - 1 );
  104.  
  105.             FPrintf( Files->Std, "\"%s\", ", rx->rxn_Name );
  106.  
  107.             if( rx->rxn_Template[0] )
  108.             FPrintf( Files->Std, "\"%s\"", rx->rxn_Template );
  109.             else
  110.             FPuts( Files->Std, Null );
  111.  
  112.             FPrintf( Files->Std, ", (APTR)%sRexxed,\n", rx->rxn_Label );
  113.         }
  114.  
  115.         rx = rx->rxn_Node.ln_Succ;
  116.         FPrintf( Files->Std, "\t(struct CmdNode *)&RexxCommands.mlh_Tail, &RexxCmds[%ld], 0, 0, ",
  117.              IE->NumRexxs - 2 );
  118.  
  119.         FPrintf( Files->Std, "\"%s\", ", rx->rxn_Name );
  120.  
  121.         if( rx->rxn_Template[0] )
  122.             FPrintf( Files->Std, "\"%s\"", rx->rxn_Template );
  123.         else
  124.             FPuts( Files->Std, Null );
  125.  
  126.         FPrintf( Files->Std, ", (APTR)%sRexxed\n};\n", rx->rxn_Label );
  127.         }
  128.  
  129.         FPrintf( Files->Std, "\nstruct MinList RexxCommands = {\n"
  130.                  "\t(struct MinNode *)&RexxCmds[0], (struct MinNode *)NULL, (struct MinNode *)&RexxCmds[%ld] };\n",
  131.              IE->NumRexxs - 1 );
  132.  
  133.     } else {
  134.  
  135.         for( rx = IE->Rexx_List.mlh_Head; rx->rxn_Node.ln_Succ; rx = rx->rxn_Node.ln_Succ ) {
  136.  
  137.         FPrintf( Files->Std, "\t\"%s\", ", rx->rxn_Name );
  138.  
  139.         if( rx->rxn_Template[0] )
  140.             FPrintf( Files->Std, "\"%s\"", rx->rxn_Template );
  141.         else
  142.             FPuts( Files->Std, Null );
  143.  
  144.         FPrintf( Files->Std, ", (APTR)%sRexxed,\n", rx->rxn_Label );
  145.         }
  146.  
  147.         FPuts( Files->Std, "\tNULL\n};\n" );
  148.     }
  149.     }
  150. }
  151. ///
  152.  
  153.